﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using Lhxm.Sgs.IDal;
using System.Reflection;

namespace Lhxm.Sgs.DalFactory
{
    /// <summary>
    /// 通过反射，创建类的实例
    /// </summary>
    public class AbstractFactory
    {
        private static readonly string assemblyPath = ConfigurationManager.AppSettings["AssemblyPath"];

        private static readonly string nameSpace = ConfigurationManager.AppSettings["NameSpace"];

        public static IuserAccountDal CreateUserAccountDal()
        {
            string fullClassName = nameSpace + ".userAccountDal";
            return CreateInstance(fullClassName) as IuserAccountDal;
        }


        private static object CreateInstance(string className)
        {
            var assembly = Assembly.Load(assemblyPath);
            return assembly.CreateInstance(className);
        }
    }
}
